package net.hancl.modules.sys.utils;

import org.apache.shiro.crypto.hash.SimpleHash;
import org.apache.shiro.util.ByteSource;

public class PassUtil {

    public final static String SALT = "hcl";

    public static String encryptPassword(String password, String name){
        ByteSource byteSource = ByteSource.Util.bytes(PassUtil.SALT + name);
        String newPassword = new SimpleHash("md5", password, byteSource, 2).toHex();

        System.out.println(newPassword);
        return newPassword;
    }

    public static void main(String[] args) {
        System.out.println(PassUtil.encryptPassword("admin", "admin"));

        ByteSource bs=ByteSource.Util.bytes("admin");
        String newPassword = new SimpleHash("md5", "admin", bs).toHex();
        System.out.println(newPassword);

        String newPassword2 = new SimpleHash("md5",  bs).toHex();

        System.out.println(newPassword2);


    }
}
